package com.uni.sofia.reader.magazine
{
	import com.uni.sofia.reader.interfaces.Comparable;
	
	import mx.controls.Image;

	[Bindable]
	/**
	 *The abstract representation for a page from a magazine, can be compared with other pages
	 * 
	 * @see Comparable 
	 */
	public class Page implements Comparable
	{
		public var  pageNumber:int;
		public var description:String;
		public var image:String;
		
		/**
		 * Default page builder(may bge Builder patterns will come in handy here)
		 * @param pageNumber
		 * 		the number of the page
		 * @description
		 * 		I don't really know what this means
		 * @image
		 * 		Image instance of the page
		 */ 
		public function Page(pageNumber:int, description:String, image:String)
		{
			if(pageNumber < 0 || image == null) throw new Error;
			
			this.pageNumber = pageNumber;
			this.description = description;
			this.image = image;
		}
			
	  public function equals(o:Object):Boolean
	  {
		  if(o == null || !(o is Page)) return false;
		  
		  if(this == o) return true;
	 
		  var page:Page = o as Page;
		  
		  if(page.description != this.description)
		  {
			  return false;
		  }
		  else if(page.pageNumber != this.pageNumber)
		  {
			  return false;
		  }
		  return true;
	  }
	  
	}
}